<template>
  <div>
    <zm-panel title="关联产品详情" :visible.sync="value" @change="close">
    <zm-table-data
        :data="tableParams.data"
        :columns="columns"
        :fetch="loadList"
        :table-params="tableParams"
        :show-page="true"
      >
      </zm-table-data>
      <div slot="footer" class="tr">
        <el-button @click="close" type="info">关闭</el-button>
      </div>
    </zm-panel>
    <!-- 产品详情 -->
    <product-detail v-model="isShowDetail" v-if="isShowDetail" :id="detailID"></product-detail>
    <physical-product-config-detail v-model="PhysicalDetailParams.visible" v-if="PhysicalDetailParams.visible" :obj="PhysicalDetailParams.obj" :id="detailID"></physical-product-config-detail>
  </div>
</template>
<script>
import productApis from '@/api/src/product'
import tableMixin from '@/mixins/zmTableMixin'
import panelMixin from '@/mixins/panelMixin'
import ProductDetail from '@/views/product/productConfig/components/Detail'
import physicalProductConfigDetail from '@/views/product/physicalProductConfig/components/physicalProductConfigDetail'

import { columns } from './const'
export default {
  name: 'LookProduct',
  components: {ProductDetail, physicalProductConfigDetail},
  mixins: [panelMixin, tableMixin],
  props: {
    productId: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      detailID: '',
      isShowDetail: false,
      PhysicalDetailParams: {
        visible: false,
        obj: {}
      }
    }
  },
  computed: {
    columns () {
      return columns(this)
    }
  },
  watch: {},
  created () {},
  methods: {
    async loadList (type) {
      const _res = await productApis.getPageList(this.assignQuery({ids: this.productId, checkStatus: '3', dataType: '-2'}))
      this.initialTableData(_res.list, _res.count)
    },
    onDetail (row) {
      if (+row.type !== 6) {
        this.isShowDetail = true
      } else {
        this.PhysicalDetailParams = {
          visible: true,
          obj: row
        }
      }
      this.detailID = row.id
    }
  }
}
</script>
<style scoped lang='scss'>
</style>
